<template lang="html">
    <div id="tmpl">
        <mt-swipe :auto="2000">
			<mt-swipe-item v-for="(item,index) in list" :key='index'>
				<img :src="item.img">
			</mt-swipe-item>
		</mt-swipe>
    </div>
</template>

<script>
import {Toast} from 'mint-ui';
import common from '../../kits/common.js';

export default {
    props: ['imgsurl'],
    data(){
        return {
            list: [],
        }
    },
    created(){
        this.getImgs();
    },
    methods: {
        getImgs(){
            //实现轮播图中的数据请求。
            //1.0 确定url
            const url = common.apij + this.imgsurl;
            //2.0 发送get请求
            this.$http.get(url).then(function (response) {
                const data = response.body;
                //错误处理
                if(data.status != 0) {
                    Toast(data.message);
                    return;
                }

                //正常逻辑;将数据赋值给list
                this.list = data.message;
            })
        }
    }
}
</script>

<style lang="css" scoped>
.mint-swipe{
		height: 220px;
	}
	.mint-swipe-item img{
		width: 100%;
	}
	.mint-swipe-item{
		/*background-color: red;*/
		width: 100%;
		/*height: 220px;*/
	}
</style>
